Advanced Debugging
About AdvDbg Consult Train Services Products Tools Community Contact  
欢迎光临 高端调试 登录 | 注册 | FAQ
 
  ACPI调试
Linux内核调试
Windows内核调试
 
  调试战役
调试原理
新工具观察
 
  Linux
Windows Vista
Windows
 
  Linux驱动
WDF
WDM
 
  PCI Express
PCI/PCI-X
USB
无线通信协议
 
  64位CPU
ARM
IA-32
  CPU Info Center
 
  ACPI标准
系统认证
Desktop
服务器
 
  Embedded Linux
嵌入式开发工具
VxWorks
WinCE
嵌入式Windows
 
  格蠹调试套件(GDK)
  格蠹学院
  小朱书店
  老雷的微博
  《软件调试》
  《格蠹汇编》
  《软件调试(第二版)》
沪ICP备11027180号-1

C/C++本地代码调试

帖子发起人: 烈火   发起时间: 2013-02-25 12:21 下午   回复: 0

Print Search
帖子排序:    
   2013-02-25, 12:21 下午
FireBurn 离线,最后访问时间: 2014/2/10 8:02:11 烈火

发帖数前50位
注册: 2013-01-26
发 贴: 28
请教,关于多线程锁的调试
Reply Quote
最近一个客户的服务软件经常发生无响应的情况,去了现场用ADPlus做了dump。原本以为会是未处理异常的情况,结果一看调用栈,真是出乎意料
0:000> ~*kbn

.  0  Id: 4bdc.835c Suspend: 1 Teb: 7ffdd000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 0013f728 7c957d0b 7c96d236 00000450 00000000 ntdll!KiFastSystemCallRet
01 0013f72c 7c96d236 00000450 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 0013f768 7c96d281 00000450 00000004 73e0e578 ntdll!RtlpWaitOnCriticalSection+0x1a3
03 0013f788 73d319af 73e0e578 00000040 00000010 ntdll!RtlEnterCriticalSection+0xa8
04 0013f7b8 73d3269e 00000010 0013f7e8 00679084 mfc42!CFixedAlloc::Alloc+0x22
05 0013f7c8 73d34378 00000010 0013fc14 006abe20 mfc42!CString::AllocBuffer+0x27
06 0013f7dc 004086ee 00679084 73e086d4 00000028 mfc42!CString::CString+0x3e
07 0013f804 00405781 0013fc14 0013fc14 77e2fbcc MyServer!CConfigInfo::GetArchiveBlockTime+0x2e 
08 0013f838 00424a29 00000000 73d31fd3 00000002 MyServer!CMyProcess::IsArchiveBlock+0x11 
09 0013f840 73d31fd3 00000002 0013fc14 0013fc14 MyServer!CMyServerDlg::OnTimer+0x39 
0a 0013f8bc 73d31b9b 00000113 00000002 00618d48 mfc42!CWnd::OnWndMsg+0x411
0b 0013f8dc 73d31b05 00000113 00000002 00000000 mfc42!CWnd::WindowProc+0x24
0c 0013f93c 73d31a58 0013fc14 00000000 00000113 mfc42!AfxCallWndProc+0x91
0d 0013f95c 73dc847d 30ed0112 00000113 00000002 mfc42!AfxWndProc+0x36
0e 0013f988 77e2b6e3 30ed0112 00000113 00000002 mfc42!AfxWndProcBase+0x39
0f 0013f9b4 77e2b874 73dc8444 30ed0112 00000113 user32!InternalCallWinProc+0x28
10 0013fa2c 77e2ba92 00000000 73dc8444 30ed0112 user32!UserCallWinProcCheckWow+0x151
11 0013fa94 77e316e5 006abedc 00000001 006abedc user32!DispatchMessageWorker+0x327
12 0013faa4 73d3125a 006abedc 00000000 0013fc14 user32!DispatchMessageA+0xf
13 0013fab4 73d46b99 00000004 0013fc14 0013fb14 mfc42!CWinThread::PumpMessage+0x3c
14 0013fad8 73d46a2e 00000004 006abea8 00000128 mfc42!CWnd::RunModalLoop+0xd9
15 0013fb14 00423b6d 006abea8 006abea8 ffffffff mfc42!CDialog::DoModal+0xe8
16 0013ff00 73d3cf74 00000000 00152517 00000000 MyServer!CMyServerApp::InitInstance+0x1dd 
17 0013ff10 005f6f29 00400000 00000000 00152517 mfc42!AfxWinMain+0x49
18 0013ff24 005f5e44 00400000 00000000 00152517 MyServer!WinMain+0x15 
19 0013ffc0 7c82f23b 00000000 00000000 7ffde000 MyServer!WinMainCRTStartup+0x134
1a 0013fff0 00000000 005f5d10 00000000 78746341 kernel32!BaseProcessStart+0x23

   1  Id: 4bdc.2d6c Suspend: 1 Teb: 7ffd9000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 023bfd00 7c957d0b 7c821d1e 00000208 00000000 ntdll!KiFastSystemCallRet
01 023bfd04 7c821d1e 00000208 00000000 023bfd48 ntdll!NtWaitForSingleObject+0xc
02 023bfd74 7c821c8d 00000208 00002710 00000000 kernel32!WaitForSingleObjectEx+0xac
03 023bfd88 4a1b6c3b 00000208 00002710 00000000 kernel32!WaitForSingleObject+0x12
04 023bffb8 7c82482f 00178d60 00000000 00000000 comsvcs!PingThread+0xf6
05 023bffec 00000000 4a1b6b45 00178d60 00000000 kernel32!BaseThreadStart+0x34

   2  Id: 4bdc.8dd0 Suspend: 1 Teb: 7ffd8000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 02e7fe3c 7c957d0b 7c96d236 00000450 00000000 ntdll!KiFastSystemCallRet
01 02e7fe40 7c96d236 00000450 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 02e7fe7c 7c96d281 00000450 00000004 73e0e578 ntdll!RtlpWaitOnCriticalSection+0x1a3
03 02e7fe9c 73d319af 73e0e578 00000040 00000003 ntdll!RtlEnterCriticalSection+0xa8
04 02e7fecc 73d3269e 00000003 02e7fefc 006786e0 mfc42!CFixedAlloc::Alloc+0x22
05 02e7fedc 73d34378 00000003 77ed6ca4 00000000 mfc42!CString::AllocBuffer+0x27
06 02e7fef0 00401cd8 006786e0 73e086d4 00000000 mfc42!CString::CString+0x3e
07 02e7ff58 00401a66 00000000 0013fe30 0013fe30 MyServer!CMyProcess::OnSysIdle+0xa8 
08 02e7ffb0 004011c9 00000000 7c82482f 0013fe30 MyServer!CMyProcess::ProcessAllDir+0x396 
09 02e7ffb8 7c82482f 0013fe30 00000000 00000000 MyServer!CMyProcess::ArchiveThread+0x19 
0a 02e7ffec 00000000 004011b0 0013fe30 00000000 kernel32!BaseThreadStart+0x34

   3  Id: 4bdc.9d10 Suspend: 1 Teb: 7ffd7000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 02f7fe0c 7c957d0b 7c96d236 00000450 00000000 ntdll!KiFastSystemCallRet
01 02f7fe10 7c96d236 00000450 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 02f7fe4c 7c96d281 00000450 00000004 73e0e578 ntdll!RtlpWaitOnCriticalSection+0x1a3
03 02f7fe6c 73d319af 73e0e578 00000040 0000000b ntdll!RtlEnterCriticalSection+0xa8
04 02f7fe9c 73d3269e 0000000b 02f7fecc 00678f20 mfc42!CFixedAlloc::Alloc+0x22
05 02f7feac 73d34378 0000000b 027f5088 006abe20 mfc42!CString::AllocBuffer+0x27
06 02f7fec0 004070ae 00678f20 73e086d4 00000002 mfc42!CString::CString+0x3e
07 02f7fee8 0041d778 0013fdf4 027f5088 00000002 MyServer!CConfigInfo::GetImageSource+0x2e 
08 02f7ff34 00411d1c 0013fdf4 027f5088 027f5088 MyServer!CMyServiceProcess::ClearFileSend+0x28 
09 02f7ff54 00411c38 027f5088 00420fd1 00000001 MyServer!CMyServiceProcess::~CMyServiceProcess+0x4c 
0a 02f7ff5c 00420fd1 00000001 0013fdf4 006ac670 MyServer!CMyServiceProcess::`scalar deleting destructor'+0x8
0b 02f7ff8c 0042122c 00000000 0013fdf4 02f7ffec MyServer!CMyServiceProvider::ClearServiceProcess+0xd1 
0c 02f7ffb0 00420c5c 00000000 7c82482f 0013fdf4 MyServer!CMyServiceProvider::Start+0xec 
0d 02f7ffb8 7c82482f 0013fdf4 00000000 00000000 MyServer!CMyServiceProvider::ServiceProviderThread+0xc 
0e 02f7ffec 00000000 00420c50 0013fdf4 00000000 kernel32!BaseThreadStart+0x34

   4  Id: 4bdc.4014 Suspend: 1 Teb: 7ffd4000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 03caff88 7c957cfb 71bb10c0 00000002 03caffb0 ntdll!KiFastSystemCallRet
01 03caff8c 71bb10c0 00000002 03caffb0 00000001 ntdll!NtWaitForMultipleObjects+0xc
02 03caffb8 7c82482f 00000000 00000000 00000000 netapi32!NetbiosWaiter+0x73
03 03caffec 00000000 71bb104d 00000000 00000000 kernel32!BaseThreadStart+0x34

   5  Id: 4bdc.80b8 Suspend: 1 Teb: 7ffd6000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 03b4fe18 7c95783b 77c585ac 000001b8 03b4ff74 ntdll!KiFastSystemCallRet
01 03b4fe1c 77c585ac 000001b8 03b4ff74 00000000 ntdll!NtReplyWaitReceivePortEx+0xc
02 03b4ff84 77c58792 03b4ffac 77c5872d 00164110 rpcrt4!LRPC_ADDRESS::ReceiveLotsaCalls+0x198
03 03b4ff8c 77c5872d 00164110 00000000 00000000 rpcrt4!RecvLotsaCallsWrapper+0xd
04 03b4ffac 77c4b110 00161310 03b4ffec 7c82482f rpcrt4!BaseCachedThreadRoutine+0x9d
05 03b4ffb8 7c82482f 001809c8 00000000 00000000 rpcrt4!ThreadStartRoutine+0x1b
06 03b4ffec 00000000 77c4b0f5 001809c8 00000000 kernel32!BaseThreadStart+0x34

   6  Id: 4bdc.728c Suspend: 1 Teb: 7ffdc000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 0119fa84 7c957d0b 7c96d236 00000450 00000000 ntdll!KiFastSystemCallRet
01 0119fa88 7c96d236 00000450 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 0119fac4 7c96d281 00000450 00000004 73e0e578 ntdll!RtlpWaitOnCriticalSection+0x1a3
03 0119fae4 73d319af 73e0e578 00000040 00000008 ntdll!RtlEnterCriticalSection+0xa8
04 0119fb14 73d3269e 00000008 0119fb44 00678e94 mfc42!CFixedAlloc::Alloc+0x22
05 0119fb24 73d34378 00000008 0335ef58 006abe20 mfc42!CString::AllocBuffer+0x27
06 0119fb38 00406a2e 00678e94 73e086d4 00000001 mfc42!CString::CString+0x3e
07 0119fb60 00412fae 0335ef58 0119fc14 006ac720 MyServer!CConfigInfo::GetStoreSCP+0x2e 
08 0119fbcc 0041438a 0119fc0c 0335ef58 0119fc30 MyServer!CMyServiceProcess::storeSCP+0x2e 
09 0119fce0 0041265e 0119fd04 0335ef58 00000000 MyServer!CMyServiceProcess::processCommands+0x1fa 
0a 0119ff94 00411e68 0119ffa4 04500e30 04500e30 MyServer!CMyServiceProcess::ProcessAssociation+0x6ae 
0b 0119ffb0 00411a8c 00000000 7c82482f 04500e30 MyServer!CMyServiceProcess::Start+0x28 
0c 0119ffb8 7c82482f 04500e30 00000000 00000000 MyServer!CMyServiceProcess::ServerThread+0xc 
0d 0119ffec 00000000 00411a80 04500e30 00000000 kernel32!BaseThreadStart+0x34

   7  Id: 4bdc.2ad0 Suspend: 1 Teb: 7ffdb000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 0396f48c 7c957d0b 7c96d236 00000450 00000000 ntdll!KiFastSystemCallRet
01 0396f490 7c96d236 00000450 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
02 0396f4cc 7c96d281 00000450 00000004 73e0e578 ntdll!RtlpWaitOnCriticalSection+0x1a3
03 0396f4ec 73d32254 73e0e578 00000001 000000b7 ntdll!RtlEnterCriticalSection+0xa8
04 0396f500 73d3274e 0436e72c 0042b156 00000008 mfc42!CFixedAlloc::Free+0x19
05 0396f508 0042b156 00000008 77b927c9 04456868 mfc42!CString::FreeData+0x13
06 0396f560 0041d335 0396f578 0436f318 00000001 MyServer!CPy::MakeSpellCode+0x246 
07 0396f58c 00415a4c 0396f804 0436f318 0067b639 MyServer!CMyServiceProcess::ConvertNameToEnglish+0xd5 
08 0396faac 004149ae 03352d08 006ac460 00060207 MyServer!CMyServiceProcess::QueryRecords+0xfdc 
09 0396fad4 0044ac65 043fbb18 00000400 0396fc34 MyServer!CMyServiceProcess::findSCPCallback+0x9e 
0a 0396fb84 0041488d 0396fbbc 04434078 00000003 MyServer!DIMSE_findProvider+0x355
0b 0396fbcc 0041440a 0396fc18 04434078 0396fc30 MyServer!CMyServiceProcess::findSCP+0x5d 
0c 0396fce0 0041265e 0396fd04 04434078 00000000 MyServer!CMyServiceProcess::processCommands+0x27a 
0d 0396ff94 00411e68 0396ffa4 043fbb18 043fbb18 MyServer!CMyServiceProcess::ProcessAssociation+0x6ae 
0e 0396ffb0 00411a8c 00000000 7c82482f 043fbb18 MyServer!CMyServiceProcess::Start+0x28 
0f 0396ffb8 7c82482f 043fbb18 00000000 00000000 MyServer!CMyServiceProcess::ServerThread+0xc 
10 0396ffec 00000000 00411a80 043fbb18 00000000 kernel32!BaseThreadStart+0x34

上网查了一下资料,用!locks命令
0:000> !locks

CritSec mfc42!_afxAlloc64+10 at 73e0e578
WaiterWoken        No
LockCount          5
RecursionCount     1
OwningThread       7aec
EntryCount         0
ContentionCount    10
*** Locked

Scanned 721 critical sections

可是线程7aec并不在上面列出的线程中,看来是意外退出了。

现在就是两个问题:
1、关于线程7aec能不能得到更多的信息。
2、CString类的使用是否安全,在代码中各线程并没有对同一个CString对象操作,但是内部还是有锁操作。

IP 地址: 已记录   报告
高端调试 » 软件调试 » C/C++本地代码调试 » 请教,关于多线程锁的调试

 
Legal Notice Privacy Statement Corporate Governance Corporate Governance
(C)2004-2020 ADVDBG.ORG All Rights Reserved.